﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:coverFlow="clr-namespace:UI.Control">
    
    <!-- Button -->
    <Style x:Key="Cover3D.Button" TargetType="{x:Type Button}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="true"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border BorderThickness="2" BorderBrush="#ffffffff" CornerRadius="2">
                            <Border Background="#00000000" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2">
                                <ContentPresenter>
                                    <ContentPresenter.BitmapEffect>
                                        <OuterGlowBitmapEffect x:Name="HoverEffect" GlowColor="White" GlowSize="0" Noise="0" Opacity="0.5" />
                                    </ContentPresenter.BitmapEffect>
                                </ContentPresenter>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true"/>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="2" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="0" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ScrollBar -->
    <Style x:Key="ScrollBar.Cover3D.LineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Border BorderThickness="2" BorderBrush="#11222222" CornerRadius="2">
                            <Border Background="#00000000" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2">
                                <ContentPresenter>
                                    <ContentPresenter.BitmapEffect>
                                        <!--OuterGlowBitmapEffect x:Name="HoverEffect" GlowColor="{Binding Source={x:Static host:Host.UIService}, Path=GlowColors.VOGColor1A}" GlowSize="0" Noise="0" Opacity="0.5" /-->
                                        <OuterGlowBitmapEffect x:Name="HoverEffect" GlowColor="Black" GlowSize="0" Noise="0" Opacity="0.5" />
                                    </ContentPresenter.BitmapEffect>
                                </ContentPresenter>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true"/>
                        <Trigger Property="ToggleButton.IsChecked" Value="true"/>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="2" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                            <BeginStoryboard>
                                <Storyboard>
                                    <Storyboard.Children>
                                        <DoubleAnimation To="0" Duration="00:00:00.1" Storyboard.TargetName="HoverEffect" Storyboard.TargetProperty="GlowSize" />
                                    </Storyboard.Children>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBar.Cover3D.PageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="#11222222" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBar.Cover3D.Thumb" TargetType="{x:Type Thumb}">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Height" Value="20"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Name="borThumb" Padding="3" CornerRadius="1" Background="#ff888888" Opacity="1"/>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                            <EventTrigger.Actions>
                                <BeginStoryboard Name="beginMouseEnter">
                                    <Storyboard>
                                        <DoubleAnimation To="0.7" Duration="0:0:0.4" Storyboard.TargetName="borThumb" Storyboard.TargetProperty="(Grid.Opacity)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                            <EventTrigger.Actions>
                                <StopStoryboard BeginStoryboardName="beginMouseEnter" />
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation To="1" Duration="0:0:0.4" Storyboard.TargetName="borThumb" Storyboard.TargetProperty="(Grid.Opacity)" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBar.Cover3D" TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="20"/>
                        </Grid.ColumnDefinitions>
                        <RepeatButton
                            Grid.Column="0"
                            Style="{StaticResource ScrollBar.Cover3D.LineButton}"
                            Width="20"
                            Command="ScrollBar.LineLeftCommand">
                            <Polygon
                                    Points="5,2 5,8 2,5"
                                    Fill="#ff888888"
                                    Stroke="#ff888888"
                                    StrokeThickness="1" />
                        </RepeatButton>
                        <Track
			              Name="PART_Track"
			              Grid.Column="1"
			              VerticalAlignment="Stretch"
			              IsDirectionReversed="False">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton
					          Style="{StaticResource ScrollBar.Cover3D.PageButton}"
					          Command="ScrollBar.PageLeftCommand" />
                            </Track.DecreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Style="{StaticResource ScrollBar.Cover3D.Thumb}"/>
                            </Track.Thumb>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton
					          Style="{StaticResource ScrollBar.Cover3D.PageButton}"
					          Command="ScrollBar.PageRightCommand" />
                            </Track.IncreaseRepeatButton>
                        </Track>
                        <RepeatButton			
                            Grid.Column="3"
                            Style="{StaticResource ScrollBar.Cover3D.LineButton}"
                            Width="20"
                            Command="ScrollBar.LineRightCommand">
                            <Polygon
                                    Points="2,2 2,8 5,5"
                                    Fill="#ff888888"
                                    Stroke="#ff888888"
                                    StrokeThickness="1" />
                        </RepeatButton>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- CoverFlow3D template -->
    <Style TargetType="{x:Type coverFlow:CoverFlow3D}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type coverFlow:CoverFlow3D}">
                    <Grid x:Name="gridRoot" ClipToBounds="True">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="5"/>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="20"/>
                            <RowDefinition/>
                            <RowDefinition x:Name="gridGapRow" Height="0"/>
                            <RowDefinition Height="20"/>
                            <RowDefinition Height="10"/>
                        </Grid.RowDefinitions>
                        <Viewport3D
                            x:Name="viewport"
                            Grid.Column="0"
                            Grid.Row="0"
                            Grid.RowSpan="6"
                            ClipToBounds="False"
                            RenderOptions.EdgeMode="Aliased">
                            <Viewport3D.Camera>
                                <PerspectiveCamera
                                    x:Name="camera" 
                                    Position="0,-0.2,4"  
                                    UpDirection="0,1,0"
                                    LookDirection="0,0.1,-1"  
                                    FieldOfView="90"
                                    NearPlaneDistance="0.125"/>
                            </Viewport3D.Camera>
                            <Viewport3D.Children>
                                <ModelVisual3D>
                                    <ModelVisual3D.Content>
                                        <Model3DGroup>
                                            <AmbientLight Color="#ff444444"/>
                                            <SpotLight
                                                Position="0,0,6"
                                                Direction="0,0,-6"
                                                InnerConeAngle="40"
                                                OuterConeAngle="45"
                                                ConstantAttenuation="0.8"
                                                LinearAttenuation="0"
                                                QuadraticAttenuation="0"
                                                Range="40"
                                                Color="White"/>
                                        </Model3DGroup>
                                    </ModelVisual3D.Content>
                                </ModelVisual3D>
                                <ModelVisual3D x:Name="visualModel">
                                </ModelVisual3D>
                            </Viewport3D.Children>
                        </Viewport3D>
                        <Button x:Name="btnSwitch" Style="{StaticResource Cover3D.Button}" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Right" Margin="5"  Width="20" Height="20">
                            <Canvas>
                                <Ellipse
                                    Fill="#00ffffff"
                                    Height="10"
                                    Width="10"
                                    StrokeThickness="2"
                                    Stroke="White"
                                    Canvas.Top="-5"
                                    Canvas.Left="-5"/>
                            </Canvas>
                        </Button>
                        <TextBlock x:Name="titleBox" Grid.Row="1" FontSize="14" FontWeight="Bold" Foreground="Red" HorizontalAlignment="Center"/>
                        <TextBlock x:Name="subTitleBox" Grid.Row="2" FontSize="12" Foreground="Red" HorizontalAlignment="Center"/>
                        <ScrollBar x:Name="scrollBar" Grid.Row="5" Margin="10,0,10,0" Orientation="Horizontal" SmallChange="1" LargeChange="4" Style="{StaticResource ScrollBar.Cover3D}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>